//
//  AppDelegate+Config.m
//  Byelone
//
//  Created by Qi Liu on 2021/1/31.
//

#import "AppDelegate+Config.h"


@implementation AppDelegate (Config)


-(void)aliToken{
    [BLHttpTool getHttpRequest:BL_ALI_UPLOADTOKEN param:@{} finish:^(NSURLSessionDataTask * _Nonnull data, NSDictionary * _Nonnull obj) {
        if (obj) {
            if ([[obj objectForKey:@"code"] integerValue] == 1) {
                NSDictionary * dic = [obj objectForKey:@"content"];
                [[BLUserManager shareUser] setAliOssConfig:dic];
            }else{
                
            }
        }
    } failedBlock:^(id  _Nonnull data, NSError * _Nonnull error) {
        
    }];
}


-(void)commonMap{
    [BLHttpTool getHttpRequest:BL_COMMON_CONFIG param:@{} finish:^(NSURLSessionDataTask * _Nonnull data, NSDictionary * _Nonnull obj) {
        if (obj) {
            if ([[obj objectForKey:@"code"] integerValue] == 1) {
                NSDictionary * dic = [obj objectForKey:@"content"];
                [BLUserManager shareUser].commonInfo = [BLInfoConfigModel mj_objectWithKeyValues:dic];
            }else{
                
            }
        }
    } failedBlock:^(id  _Nonnull data, NSError * _Nonnull error) {
        
    }];
}

- (void)getUserInfo{
    if ([BLUserManager shareUser].userPpu &&(![[BLUserManager shareUser].registerStep isEqualToString:@"1"]&&![[BLUserManager shareUser].registerStep isEqualToString:@"2"])) {
        [BLHttpTool getHttpRequest:BL_USER_CENTER param:@{} finish:^(NSURLSessionDataTask * _Nonnull data, NSDictionary * _Nonnull obj) {
            BLInfoUserInfo *model = [BLInfoUserInfo mj_objectWithKeyValues:obj[@"content"]];
            [BLUserManager shareUser].userInfo = model;
            
            [BLHttpTool getHttpRequest:BL_USER_BASEINFO param:@{} finish:^(NSURLSessionDataTask * _Nonnull data, NSDictionary * _Nonnull obj) {
                BLInfoBaseInfo *baseInfo = [BLInfoBaseInfo mj_objectWithKeyValues:obj[@"content"]];
                [BLUserManager shareUser].baseInfo = baseInfo;
                
                [BLHttpTool getHttpRequest:BL_USER_ETAIL param:@{} finish:^(NSURLSessionDataTask * _Nonnull data, NSDictionary * _Nonnull obj) {
                    BLInfoDetailInfo *detailInfo = [BLInfoDetailInfo mj_objectWithKeyValues:obj[@"content"]];
                    [BLUserManager shareUser].detailInfo = detailInfo;
                    
                } failedBlock:^(id  _Nonnull data, NSError * _Nonnull error) {
                    
                }];
            } failedBlock:^(id  _Nonnull data, NSError * _Nonnull error) {
                
            }];
        } failedBlock:^(id  _Nonnull data, NSError * _Nonnull error) {
        }];
    }
}

@end
